package dto

import (
	"tuowei.com/app/admin/models"
	"tuowei.com/common/dto"
	common "tuowei.com/common/models"
)

type SysConsultWZGetPageReq struct {
	dto.Pagination `search:"-"`
	ConsultWZTitle string `form:"consult_wz_title" json:"consult_wz_title" search:"type:contains;column:consult_wz_title;table:sys_consult_wz" comment:"文章标题"` // 文章标题
	ConsultWZStart string `form:"beginTime" json:"beginTime" search:"type:gte;column:updated_at;table:sys_consult_wz" comment:"开始日期"`                          // 开始日期
	ConsultWZEnd   string `form:"endTime" json:"endTime" search:"type:lte;column:updated_at;table:sys_consult_wz" comment:"结束日期"`                              // 结束日期
	WZTop          string `form:"wz_top" json:"wz_top" search:"type:exact;column:wz_top;table:sys_consult_wz" comment:"置顶文章"`                                  // 置顶文章
	//WZHot             string `json:"wz_hot" search:"type:exact;column:wz_hot;table:sys_consult_wz" comment:"热门文章"`                        // 热门文章
	Province string `form:"province" json:"province" search:"type:contains;column:province;table:sys_consult_wz" comment:"适用地区"`
}

func (m *SysConsultWZGetPageReq) GetNeedSearch() interface{} {
	return *m
}

type SysConsultWZInsertReq struct {
	ConsultWZId           int    `json:"consult_wz_id" comment:"文章ID"`           // 文章ID
	ConsultWZTitle        string `json:"consult_wz_title" comment:"文章标题"`        // 文章标题
	WZUrl                 string `json:"wz_url" comment:"文章封面url"`               // 文章封面url
	ConsultWZIntroduction string `json:"consult_wz_introduction" comment:"文章描述"` // 文章描述
	ConsultWZContent      string `json:"consult_wz_content" comment:"文章内容"`      // 文章内容
	WZTop                 string `json:"wz_top" comment:"置顶文章"`                  // 置顶文章
	WZHot                 string `json:"wz_hot" comment:"热门文章"`                  // 热门文章
	Province              string `json:"province" comment:"适用地区"`
	common.ControlBy
}

func (s *SysConsultWZInsertReq) Generate(model *models.SysConsultWZ) {
	//model.CourseId = s.CourseId
	model.ConsultWZId = s.ConsultWZId
	model.ConsultWZTitle = s.ConsultWZTitle
	model.ConsultWZIntroduction = s.ConsultWZIntroduction
	model.ConsultWZContent = s.ConsultWZContent
	model.Province = s.Province
	model.WZUrl = s.WZUrl
	if s.WZTop != "1" {
		model.WZTop = "2"
	} else {
		model.WZTop = s.WZTop
	}
	if s.WZHot == "" {
		model.WZHot = "1"
	} else {
		model.WZHot = s.WZHot
	}
}

func (s *SysConsultWZInsertReq) GetId() interface{} {
	return s.ConsultWZId
}

type SysConsultWZUpdateReq struct {
	ConsultWZId           int    `json:"consult_wz_id" comment:"文章ID"`           // 文章ID
	ConsultWZTitle        string `json:"consult_wz_title" comment:"文章标题"`        // 文章标题
	WZUrl                 string `json:"wz_url" comment:"文章封面url"`               // 文章封面url
	ConsultWZIntroduction string `json:"consult_wz_introduction" comment:"文章描述"` // 文章描述
	ConsultWZContent      string `json:"consult_wz_content" comment:"文章内容"`      // 文章内容
	WZTop                 string `json:"wz_top" comment:"置顶文章"`                  // 置顶文章
	WZHot                 string `json:"wz_hot" comment:"热门文章"`                  // 热门文章
	Province              string `json:"province" comment:"适用地区"`
	common.ControlBy
}

func (s *SysConsultWZUpdateReq) Generate(model *models.SysConsultWZ) {
	if s.ConsultWZId != 0 {
		model.ConsultWZId = s.ConsultWZId
	}
	if s.ConsultWZTitle != "" {
		model.ConsultWZTitle = s.ConsultWZTitle
	}
	if s.WZUrl != "" {
		model.WZUrl = s.WZUrl
	}
	if s.ConsultWZIntroduction != "" {
		model.ConsultWZIntroduction = s.ConsultWZIntroduction
	}
	if s.ConsultWZContent != "" {
		model.ConsultWZContent = s.ConsultWZContent
	}
	if s.WZTop != "" {
		model.WZTop = s.WZTop
	}
	if s.WZHot != "" {
		model.WZHot = s.WZHot
	}
	if s.Province != "" {
		model.Province = s.Province
	}
	model.CreateBy = s.CreateBy
}

func (s *SysConsultWZUpdateReq) GetId() interface{} {
	return s.ConsultWZId
}

type SysConsultWZGetReq struct {
	Id int `uri:"id"`
}

func (s *SysConsultWZGetReq) GetId() interface{} {
	return s.Id
}

type SysConsultWZDeleteReq struct {
	Ids []int `json:"ids"`
}

func (s *SysConsultWZDeleteReq) GetId() interface{} {
	return s.Ids
}
